<template>
	<view class="box">
		<view class="box1" v-if="state">
			<view class="img">
				<image :src="status[state].img" mode="widthFix"></image>
			</view>
			<view class="status f34 bold">{{status[state].stateText}}</view>
			<view class="desc f30">{{status[state].desc}}</view>
			<view class="btn" @click="Funs(status[state].btnText)" v-if="status[state].btnText">
				<button type="default" open-type="contact" v-if="status[state].btnText=='联系客服'"></button>
				{{status[state].btnText}}</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				type: 1, // 1.申请美食官 2.申请买手 3.申请骑手
				state: '', //0.审核中 1.审核成功 2.审核失败
				status: [{
						state: 1,
						stateText: '审核中',
						img: 'https://jw.xzsw2021.com/static/user/icon_269@2x.png',
						desc: '您申请的美食分享官，正在等待后台审核',
						btnText: '返回个人中心'
					},
					{
						state: 2,
						stateText: '审核成功',
						img: 'https://jw.xzsw2021.com/static/user/icon_274@2x.png',
						desc: '',
						btnText: ''
					},
					{
						state: 0,
						stateText: '审核失败',
						img: 'https://jw.xzsw2021.com/static/user/icon_274@2x.png',
						desc: '很抱歉您的认证信息中有部分信息未能通过审 核，请重新填写信息',
						btnText: '重新申请'
					}
				], //审核状态
			}
		},
		onLoad(options) {
			this.type = options.type || 1;
			// 
			if (this.type == 1) { //美食官
			    this.state=options.state

			} else { //买手--骑手
				this.status[0].desc = '您的申请正在审核中、请耐心等待、 如需帮助、可拨打客服电话';
				this.status[0].btnText = '联系客服';
				this.status[1].desc = '您的申请已通过、报到时请携带 身份证原件、健康证原件';
				this.status[1].btnText = '';
				this.status[2].desc = '很抱歉您的认证信息中有部分信息未能通过审 核，请重新填写信息';
				this.getstatus()
			}

		},
		methods: {
			// 获取审核状态
			getstatus() {
				uni.showLoading({
					mask:true
				})
				this.$request('user/get_apply?type=' + (this.type - 1), {}, 'GET').then(res => {
					uni.hideLoading()
					if(res.data&&res.data.application_id){
						this.state=res.data.status+''
						
					}else{
						uni.redirectTo({
							url: "/pages/user/distribution/apply?type="+this.type
						})
					}
				})
			},
			// 
			Funs(text) {
				if (text == '返回个人中心') {
					uni.switchTab({
						url: '/pages/user/user'
					})
				} else if (text == '重新申请') {
					uni.redirectTo({
						url: "/pages/user/distribution/apply?type="+this.type
					})
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.box {
		.box1 {
			overflow: hidden;
			text-align: center;

			.img {
				margin: 210rpx auto 0;
				width: 406rpx;
				height: 301rpx;

				image {
					width: 100%;
					height: 100%;
				}
			}

			.status {
				margin: 80rpx 0 18rpx;
			}

			.desc {
				margin: 0 auto;
				width: 500rpx;
				color: #666;
			}

			.btn {
				margin: 200rpx auto 0;
				width: 300rpx;
				height: 100rpx;
				line-height: 100rpx;
				text-align: center;
				color: #fff;
				font-size: 32rpx;
				background: linear-gradient(64deg, #2BCCA5, #22B591);
				box-shadow: 0rpx 4rpx 6rpx 0rpx rgba(20, 187, 146, 0.4);
				position: relative;
				border-radius: 10rpx;
				button{
					width: 100%;
					height: 100%;
					position: absolute;
					opacity: 0;
				}
			}
		}
	}
</style>
